#ifndef _BSP_CAN_H
#define _BSP_CAN_H

#include <stdint.h>
#include <stdlib.h> 
#include <string.h> 
#include "can.h"

#define CAN_MAX_NUM 14
#define CAN_NUM 2

#pragma pack(1)
typedef struct can
{
	CAN_HandleTypeDef* CANx;
	CAN_TxHeaderTypeDef tx_conf;
	uint32_t tx_id;
	uint32_t tx_mailbox;
	uint8_t tx_buf[8];
	uint32_t rx_id;
	uint8_t rx_len;
	uint8_t rx_buf[8];
	void (* can_module_callback)(struct can *);
	void* id;
} CANInstance;
#pragma pack()

typedef struct 
{
	CAN_HandleTypeDef* CANx;
	uint32_t tx_id;
	uint32_t rx_id;
	void (* can_module_callback)(CANInstance *);
	void* id;
} CAN_Init_Config_s;

CANInstance* CANInit(CAN_Init_Config_s* _config);

uint8_t CANSend(CANInstance *_instance,float timeout);
#endif 
